<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>返利开票申请表-针对支付表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">申请时间</div>
                    <div class="field">
                        <input name="applyTm" id="applyTm" type="text"   validate="{required:true}"  class="ui-datepicker" value="">
                    </div>
                </div>
				<div class="fieldBox">
                    <div class="label">申请人</div>
                    <div class="field">
                        <input name="applyMgrNm" id="applyMgrNm"  validate="{required:true}" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33" id="searchPrjStsCdId">
	                 <div class="label">报销状态</div>
                       <div class="field">
                          <select name="audStsCd"  id="audStsCd" >
                           <option value="  " selected="selected">--请选择--</option>
	                         <c:forEach items="${audStsCdList}" var="opt">
	                          	<option value="${opt.key}">${opt.value}</option>
	                         </c:forEach>
                        </select>
                       </div>
                </div>
                <div class="fieldBox" id="searchBuOrgCdId">
                    <div class="label">所属事业部</div>
                    <div class="field">
                        <select name="buOrgCd" id="buOrgCd">
                            <option value=" " seleted>请选择</option>
                            <c:forEach items="${orgList}" var="org">
                                <option value="${org.key}">${org.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="addBtn" class="sq-button sq-button-round">报销申请</span>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    var form;
    $(function (){
    	 form = $("#searchBar").ligerForm({
             validate: true
         });
    	 
    	 
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/project/prjRbtbillApply/initList.do',
            method: 'get',
            columns: [
		{display: '申请时间', name: 'applyTm', minWidth: 100, align: 'center',render:renderDate, enabledSort: false},
		{display: '申请人', name: 'applyMgrNm', minWidth: 100, align: 'center', enabledSort: false},
		{display: '报销状态', name: 'audStsNm', minWidth: 100, align: 'center',enabledSort: false},
		{display: '所属事业部', name: 'buOrgNm', minWidth: 100, align: 'center',enabledSort: false},
		{display: '开票金额', name: 'billAmt', minWidth: 100, align: 'center', 
			render: function (rowdata, index, value) {
                return '¥'+FormatMoney(rowdata.billAmt / 100);
            },enabledSort: false},
            
		//{display: '返利金额(分)', name: 'rbtAmt', minWidth: 100, align: 'left', enabledSort: false},
		//{display: '开票税点', name: 'billTpPct', minWidth: 100, align: 'left', enabledSort: false},
		{display: '开票税点金额', name: 'billTpAmt', minWidth: 100, align: 'center', 
			render: function (rowdata, index, value) {
                return '¥'+FormatMoney(rowdata.billTpAmt / 100);
            },enabledSort: false},
		//{display: '申请人ID', name: 'applyMgrId', minWidth: 100, align: 'left', enabledSort: false},
		{display: '流程编号', name: 'pNo', minWidth: 100, align: 'center', 
			render: function (rowdata, index, value) {
                if(rowdata.pInstId){
                    var h='<a href="javascript:showFlow(';
                    h+="'"+rowdata.pInstId+"'";
                    h+=",'"+rowdata.flowAudStsCd+"'";
                    h+=",'"+rowdata.id+"'";
                    h+=')">'+rowdata.pNo+'</a>';
                    return h;
                }

            },enabledSort: false},
		//{display: '申请人组织架构代码', name: 'applyMgrOrgCdNm', minWidth: 100, align: 'left', enabledSort: false},
		//{display: '所属事业部', name: 'buOrgCdNm', minWidth: 100, align: 'left', enabledSort: false},
		//{display: '备注', name: 'applyRem', minWidth: 100, align: 'left', enabledSort: false},
		/* {
			display: '操作',width: 150,
			render: function (rowdata, rowindex, value){
				var h1 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="modifySplBullMsg('+rowdata.id+')"><i class="sqBtnIco_4"></i>附件消息</a>'
				return h1;
			} 
		}*/
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            //isScroll: false,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: false,
            alternatingRow: false
            /* onRenderComplete: function () {
             iframeResize ();
             } */
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });
        
        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
            <%-- $.ligerDialog.open({
                width: 900,
                height: 600,
                title: '申请开票',
                url:'<%=path%>/project/prjRbtbillApply/toAddPage.do'
            }); --%>
            Add_navTab("PrjRbtbillApply_1", "报销申请", '<%=path%>/project/prjRbtbillApply/toAddPage.do', callback);
        });
		
        /* 修改 */
        $("#changeBtn").click(function (event) {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length != 1) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                return;
            }
            var _id=selectedRows[0].id;
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '修改返利开票申请表-针对支付表',
                url:'<%=path%>/project/prjRbtbillApply/toModifyPage.do?id='+_id
            });
            //Add_navTab('PrjRbtbillApply_2'+_id, "修改返利开票申请表-针对支付表", '<%=path%>/project/prjRbtbillApply/toModifyPage.do?id='+_id, callback);
        });

        /* 删除 */
        $("#delBtn").click(function () {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }

            $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/project/prjRbtbillApply/removeByIds.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        });
    });
  //格式化时间
    function renderDate(rowdata, index, value){
    	var dateStr = "";
    	if(null != value&&value!=''){
    		var date = new Date(value);
    		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    	}
    	return dateStr;
    }
	//显示流程
	function showFlow(_pInstId,_audStsCd,_businessKey){
		if(StringUtils.isEmpty(_pInstId)){
			UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
			return;
		}
		var _formUrl = "/project/prjRbtbillBscInfo/toListPage.do?isFlow=1@@applyId=";
		var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
		Add_navTab('tab_prj_rbtbill_apply_flow_'+_pInstId,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
	}
    <%-- /* 修改 */
    function modifySplBullMsg(_id){
    	Add_navTab('SplBullMsgInfo_2'+_id, "跳转附加信息页", '<%=path%>/project/prjRbtbillBscInfo/toListPage.do?applyId='+_id, callback);
    } --%>

</script>

</body>
</html>
